<?php

namespace app\api\controller;

use \think\Request;
use app\common\business\user\Hd as hdBn;
use app\common\business\http\wechat\Wechat as wechatHttp;
use app\common\business\User as userBn;
use app\common\business\Guess as guessBn;
class H5 extends \app\common\controller\HomeBase {

  
    /**
     *
     * 分享受api
     *
     * */
    public function wxshareapi() {
        try { 
            $params = input();   
            $JsApipub = new \app\extra\H5WeixinSDK\V3\JsApipub();
            $backurl =isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'https://h5.atsoo.cn/h5/index.htm';
            $data = $JsApipub->getjsapistr($backurl);
         
            $this->_echoSuccessMessage("success", $data);
        } catch (\Exception $e) {
            $this->_echoErrorMessage($e->getMessage(), $e->getCode());
        }
    }

	/**
     *
     * 分享受api
     *
     * */
    public function shareshow() {
         

		 try {
            $params = input();
            $params['user_id'] = $params['id'];
            $data = guessBn::myguess($params);
			if(isset($data['guess_img'])){
			$data['guess_img']=str_replace("qhimg.qiu7.net","h5.atsoo.cn",$data['guess_img']);
			}
            $this->_echoSuccessMessage('', $data);
        } catch (\Exception $e) {
            $this->_echoErrorMessage($e->getMessage(), $e->getCode());
        }
    }

	
    /**
     * 保存用户
     */
    public function savesharemobile() {
        try {
            $params = input();
            $validate = Validate('Guess');
            $params = $validate->scene('savemobile')->check($params);
            if (!$params) {
                exception($validate->getError(), 10000003);
            }
           
            $data = userBn::savesharemobile($params);
 
            $this->_echoSuccessMessage('', $data);
        } catch (\Exception $e) {
            $this->_echoErrorMessage($e->getMessage(), $e->getCode());
        }
    }

}
